/**
 * 
 */
package com.jjt.kiki.util;

import java.util.List;

import org.springframework.validation.FieldError;

/**
 * @author jiangjintai
 *
 */
public class MyFieldErrorMessageFormatter {
	public static String formatter(FieldError f){
		StringBuilder sb = new StringBuilder();
		sb.append("(");
		sb.append(f.getField());
		sb.append("#");
		sb.append(f.getDefaultMessage());
		sb.append(")");
		return sb.toString();
	}
	public static String formatter(List<FieldError> fs){
		StringBuilder sb = new StringBuilder();
		sb.append("error count#"+fs.size()+"   ");
		for(FieldError f:fs){
			sb.append("(");
			sb.append(f.getField());
			sb.append("#");
			sb.append(f.getDefaultMessage());
			sb.append(")");
			sb.append(" | ");
		}
		sb.setLength(sb.length()-2);
		return sb.toString();
	}
}
